<script src="../media/system/js/mootools-core.js" type="text/javascript"></script>
<script src="../media/system/js/core.js" type="text/javascript"></script>
<form action="index.php?top=page&option=com_frtown" method="post" name="adminForm" id="adminForm">
  <!-- LEFT --> 
  <?php echo $this->loadTemplate('search','default') ?> 
  <!-- END LEFT --> 
  
  <!-- CONTENT -->
  <div id="jm-content">
    <h3 class="jm-title">
    <?php
            if($this->sr=='1')
            {
                echo '検索結果';
            }
            else echo '新着情報';
            ?>
    </h3>
    <div class="">
    <?php $result = $this->result;
            if(!empty($result)){
                foreach ($result as $key=>$town){
        ?>
        <div class="cc">
            <h2 style="position: relative;">
                <span class="id-cc"><?php echo $town->TOWN_CODE; ?></span>
               	<span><?php echo $town->TOWN_NAME; ?></span>
                <span>（<?php echo $town->TOWN_KANA; ?>）</span>
                <span style="float: right;position:absolute;right:5px;top:1px;"> 
                    <button href="index.php?top=page&option=com_frtown&task=detail&id=<?php echo $town->TOWN_CODE; ?>">詳細情報へ</button>
                </span>
            </h2>
            <table cellspacing="0" cellpadding="0" width="700" border="0" style="line-height:17px">
                <tbody>
                  <tr>
                    <td width="150"><?php if ($town->TOWN_POST!=null) echo '〒'.$town->TOWN_POST; ?></td>
                    <td width="340" colspan="2"><?php echo $town->TOWN_ADD1; ?></td>
                  </tr>
                  <tr>
                    <td width="150"></td>
                    <td width="340" colspan="2"><?php echo $town->TOWN_ADD2; ?></td>
                  </tr>
                  <tr>
                    <td></td>
                    <td>Tel：<?php echo $town->TOWN_TEL; ?></td>
                    <td>Fax：<?php echo $town->TOWN_FAX; ?></td>
                    <td width="180"></td>
                  </tr>
                </tbody>
              </table>
            <hr/>
            <table cellspacing="0" cellpadding="0" width="100%" border="0">
                <tbody>
                  <tr>
                    <td width="20%">【URL】</td>
                    <td width="80%" colspan="2"><a href="<?php echo $town->TOWN_URL; ?>"  target="_blank"><?php echo $town->TOWN_URL; ?></a></td>
                  </tr>
                  <tr>
                    <td width="150" style="vertical-align: top;">【センター・クラブ】</td>
                    <td width="340" colspan="2"><?php 
                                $model = $this->getModel();
                                $this->ocba = $model->getOCBA($town->TOWN_CODE); //Lay OCBA theo TOWN_CODE
                                if($this->ocba != null){
                                    foreach($this->ocba as $k=>$ocba){
                                        $str = substr($ocba->OCBA_CODE,0,1); //Cat ky tu dau cua OCBA_CODE de kiem tra la center hay club
                                        if($str == '0'){
                                            echo "<a href='index.php?top=page&option=com_frcenter&task=detail&id=$ocba->OCBA_CODE'>$ocba->OCBA_NAME</a>";
                                        }
                                        else{
                                            echo "<a href='index.php?top=page&option=com_frclub&task=detail&id=$ocba->OCBA_CODE'>$ocba->OCBA_NAME</a>";
                                        }
                                    }
                                }
                             ?></td>
                  </tr>
                </tbody>
              </table>
            
        </div>
    
    <?php
        }
        }
         else{
                echo "<center>データは見つかりませんでした</center>";
            }
    ?>
    
        <table style="margin: auto;">
            <tfoot>
    			<tr style="text-align: center;">
    				<td colspan="15" style="text-align: center;">
    				    <?php echo $this->pagination->getListFooter(); ?>	
                    </td>
    			</tr>
    		</tfoot>
        </table>
        <input type="hidden" name="task" value=""/>
        <input type="hidden" name="boxchecked" value="0"/>
    
    </div>
    
    <!-- ------------>
    
    
    
  </div>
  <!-- END RIGHT -->
  <input type="hidden" name="task" value="">
  <input type="hidden" name="boxchecked" value="0">
</form>
<script>
    jq(document).ready(function() {
        
        // show a dialog box when clicking on a link
        jq('#icon').bind('click', function(e) {
            e.preventDefault();
            jq.Zebra_Dialog('', {
                source:  {'ajax': 'index.php?top=page&option=com_frcenter&task=icon&tmpl=component'},
                height: 500,
                width: 500,
                title:  '【アイコン】ページ',
                type:  '',

            });
        });
    })
</script>